package com.spring.mvc.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Properties;

/**
 * 加载properties文件
 * @author liujian
 *
 */
public class Prompt {

	private static Properties param=new Properties();
	private static String filePath="properties/prompt.properties";
	
	public static String get(String key){
		if(null == param || param.size()==0){
			read();
		}
		return param.getProperty(key);
	}
	
	public static void read(){
		try {
			File file=new File(URLDecoder.decode(Prompt.class.getResource("/").getPath()+filePath,"UTF-8"));
			FileInputStream fis=new FileInputStream(file);
			param.load(fis);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
